import http from '@/api';
import { ADMIN_MODULE } from '@/api/helper/prefix';
import type { IPage, IResultData } from '@/api/types';
import type { DtuFtpInfoQuery, DtuFtpInfoRow, DtuFtpInfoForm } from '../../types/dtuinfo/dtuFtpInfo';

/**
 * 获取DTU FTP信息列表
 * @param params 查询参数
 * @returns 分页数据
 */
export const getDtuFtpInfoListApi = (params: DtuFtpInfoQuery) => {
  return http.get<IPage<DtuFtpInfoRow>>(`${ADMIN_MODULE}/dtu-ftp-info`, params);
};

/**
 * 更新DTU FTP信息
 * @param params 表单数据
 * @returns 结果
 */
export const updateDtuFtpInfoApi = (params: DtuFtpInfoForm) => {
  return http.put<IResultData<null>>(`${ADMIN_MODULE}/dtu-ftp-info`, params);
};

/**
 * 删除DTU FTP信息
 * @param ids ID数组
 * @returns 结果
 */
export const removeDtuFtpInfoApi = (ids: string[]) => {
  return http.delete<IResultData<null>>(`${ADMIN_MODULE}/dtu-ftp-info`, { ids });
};

/**
 * 绑定设备
 * @param params 绑定参数
 * @returns 结果
 */
export const bindDeviceApi = (params: { deviceId: string; deptId: number }) => {
  return http.post<IResultData<null>>(`${ADMIN_MODULE}/dtu-ftp-info/bind`, params);
};

/**
 * 根据部门ID获取车辆列表
 * @param deptId 部门ID
 * @param params 分页参数
 * @returns 车辆列表
 */
export const getVehiclesByDeptIdApi = (deptId: number, params: DtuFtpInfoQuery) => {
  return http.get<IPage<DtuFtpInfoRow>>(`${ADMIN_MODULE}/dtu-ftp-info/dept/${deptId}`, params);
};